package com.js.data.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.js.data.common.api.CommonResult;
import com.js.data.common.query.BaseQueryInfo;
import com.js.data.system.service.LogService;
import com.js.data.system.vo.LogPageVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 日志控制层
 */
@RestController
@RequestMapping("/sys")
public class LogController {


    @Resource
    private LogService logService;

    /**
     * 日志分页
     *
     * @param query 查询条件
     * @return IPage<LogPageVO>
     */
    @PreAuthorize("@perm.check('system:log:list')")
    @GetMapping(value = "/log")
    public CommonResult<IPage<LogPageVO>> pageLog(@ModelAttribute BaseQueryInfo query) {
        return CommonResult.success(logService.pageLog(query));
    }


    /**
     * 获取错误日志详情
     *
     * @param id id
     * @return String
     */
    @GetMapping(value = "/log/{id}")
    public CommonResult<String> errorLogDetail(@PathVariable Long id) {
        return CommonResult.success(logService.errorLogDetail(id));
    }
}
